<?php
namespace Admin\Controller;

class IndexController extends AdminController {
    public function index(){
        $now = new \DateTime();
        $start = $now->sub(new \DateInterval('P1M'));//一个月
        $end = $now->add(new \DateInterval('P1D'));
        
        $start_date = $start->format('Y-m-d');
        $end_date = $end->format('Y-m-d');
        //统计每天的订单数及金额
        $modelOrder = M('Order');
        $sql = "SELECT date(posttime) as pdate,count(*) as t_num,sum(n_real_amt+n_traff_real_prm+n_tax_real_prm) as t_total,sum(n_real_amt) as t_amt, sum(n_traff_real_prm) as t_traff_prm,sum(n_tax_real_prm) as t_tax_prm FROM __TABLE__ where posttime between '$start_date' and '$end_date' group by date(posttime)";
        $res = $modelOrder->query($sql);
        
        $this->meta_title = '管理首页';
        
        $this->display();
    }
}